#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
//#include <LengthUnit.h>
#include <Length.h>
#include <LengthUnit.h>

#include <sstream>
#include <iostream>

#include <Format.h>
#include <OutputBaseUnit.h>
#include <OutputCascade.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

using namespace std;

FIXTURE(Length)
{
	TEST(should compare MILE with YARD under Length system: 1 MILE == 1760 YARD)
	{	
		Length theMile(1, MILE);
		Length theYard(1760, YARD);
		ASSERT_EQ(theMile, theYard); 
	}
	
	TEST(should compare FEET with YARD under Length system: 3 FEET == 1 YARD)
	{
		ASSERT_TRUE(Length(3, FEET) == Length(1, YARD)); 
	}
	
	TEST(should compare FEET with INCH under Length system: 1 FEET == 12 INCH)
	{
		ASSERT_TRUE(Length(1, FEET) == Length(12, INCH)); 
	}
	
	TEST(should get the sum among unit of FEET, INCH, MILE, or YARD under Length system: (1 MILE + 2 YARD + 3 FEET + 4 INCH) == 63412 INCH)
	{
		ASSERT_TRUE(Length(1, FEET) + Length(2, YARD) + Length(3, FEET) + Length(4, INCH) == Length(63412, INCH)); 
	}
	
	TEST(should print out the Length object with its largest Unit under Length system like: "35 INCH == 2 FEET 11 INCH")
	{
		Length length(35, INCH); 
                stringstream sio;
		length.print(sio, cascadeFormatter);
		ASSERT_EQ(string("2 FEET 11 INCH"), sio.str());
	}
	
	TEST(should print out the Length object with its largest Unit under Length system like: "38 INCH == 1 YARD 2 INCH")
	{
		Length length(38, INCH); 
                stringstream sio;
		sio << length.format(outputCascade);
		ASSERT_EQ(string("1 YARD 2 INCH"), sio.str());
	}
	
	TEST(should print out the Length object with its largest Unit under Length system like: "48 INCH == 1 YARD 1 FEET")
	{
		Length length(48, INCH); 
                stringstream sio;
		sio << length.format(outputCascade);
		ASSERT_EQ(string("1 YARD 1 FEET"), sio.str()); 
	}
	
	TEST(should print out the Length object with its largest Unit under Length system like: "5 FEET == 1 YARD 2 FEET")
	{
		Length length(5, FEET); 
                stringstream sio;
		sio << length.format(outputCascade);
		ASSERT_EQ(string("1 YARD 2 FEET"), sio.str()); 
	}

	TEST(should print out the Length object with its largest Unit under Length system like: "1781 YARD == 1 MILE 21 YARD")
	{
		Length length(1781, YARD); 
                stringstream sio;
		sio << length.format(outputCascade);
		ASSERT_EQ(string("1 MILE 21 YARD"), sio.str());  
	}	

	TEST(should print out the Length object with its largest Unit under Length system like: "2 INCH == 2 INCH")
	{
		Length length(2, INCH); 
		OutputOneUnit outputOneUnit(INCH);
                stringstream sio;
		sio << length.format(outputOneUnit);
		ASSERT_EQ(string("2 INCH"), sio.str());  
	}	

	TEST(should print out the Length object with its largest Unit under Length system like: "2 FEET == 24 INCH")
	{
		Length length(2, FEET); 
		OutputOneUnit outputOneUnit(INCH);
                stringstream sio;
		sio << length.format(outputOneUnit);
		ASSERT_EQ(string("24 INCH"), sio.str());  
	}	

	TEST(should print out the Length object with its largest Unit under Length system like: "3 YARD == 108 INCH")
	{
		Length length(3, YARD); 
		OutputOneUnit outputOneUnit(INCH);
                stringstream sio;
		sio << length.format(outputOneUnit);
		ASSERT_EQ(string("108 INCH"), sio.str());  
	}	

	TEST(should print out the Length object with its largest Unit under Length system like: "2 MILE == 126720 INCH")
	{
		Length length(3, YARD); 
		OutputOneUnit outputOneUnit(INCH);
                stringstream sio;
		sio << length.format(outputOneUnit);
		ASSERT_EQ(string("126720 INCH"), sio.str());  
	}	

};

// 1 mile = 1760 yard = 5280 FEET = 63360 INCH
// 1 yard = 3 feet = 36 inch
// 1 feet = 12 inch
